package com.qpf.mycms.api.util;

import java.util.regex.Pattern;

public final class ValidatorUtil {
    private ValidatorUtil(){}

    private static final String EMAIL_REGEX = "^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
    private static final String PHONE_REGEX = "^1[3-9]\\d{9}$";

    public static boolean validateEmail(String email){
        return validate(EMAIL_REGEX, email);
    }
    public static boolean validateMobile(String mobile){
        return validate(PHONE_REGEX, mobile);
    }

    public static boolean validate(String rule, String value) {
        return Pattern.compile(rule).matcher(value).matches();
    }
}
